﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SuperCalculator
{
    class Program
    {
        static void Main(string[] args)
        {
            for (; ; ) {
                try {
                    Console.WriteLine("请输入要计算的表达式:");
                    string str = Console.ReadLine();

                    Expression exp = new Expression(str);
                    Console.Write(str + " = ");
                    Console.WriteLine(exp.Calculator().ToString());

                } catch (ExpressionException ex) {
                    Console.WriteLine(string.Format("表达式出错. 出错类型:{0}, 出错位置{1}", ex.Message, ex.Index));
                }

                Console.WriteLine();
            }
        }
    }
}
